<!DOCTYPE html>
<html lang="zh-hans">

<head>
    
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="HandheldFriendly" content="True" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta name="generator" content="Hugo 0.109.0">


<link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/dsrkafuu/dsr-cdn-main@1/images/favicons/dsrca.ico" />



<title>PSO粒子群算法 - OffSummer</title>


<meta name="author" content="RQY" />


<meta name="description" content="A minimal Hugo theme with nice theme color." />


<meta name="keywords" content="机器学习" />


<meta property="og:title" content="PSO粒子群算法" />
<meta name="twitter:title" content="PSO粒子群算法" />
<meta property="og:type" content="article" />
<meta property="og:url" content="/post/pso/" /><meta property="og:description" content="概述
粒子群算法的思想源于对鸟群觅食行为的研究，鸟群通过集体的信息共享使群体找到最优的目的地。" />
<meta name="twitter:description" content="概述
粒子群算法的思想源于对鸟群觅食行为的研究，鸟群通过集体的信息共享使群体找到最优的目的地。" /><meta property="og:image" content="/img/og.png" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="/img/og.png" />


<style>
    @media (prefers-color-scheme: dark) {
        body[data-theme='auto'] img {
            filter: brightness(60%);
        }
    }

    body[data-theme='dark'] img {
        filter: brightness(60%);
    }
</style>




<link rel="stylesheet" href="/assets/css/fuji.min.b4a21b5d3eb1d0a51297e31230a65fc25e387843e45ec3a2d9176cd8d163c216d99b9b13a618b28f537c3b559ec8a408183b0fbfad48daddb9befa7d3ef90eed.css" integrity="sha512-tKIbXT6x0KUSl&#43;MSMKZfwl44eEPkXsOi2Rds2NFjwhbZm5sTphiyj1N8O1WeyKQIGDsPv61I2t25vvp9PvkO7Q==" />








</head>

<body
  data-theme="auto"
  data-theme-auto='true'
  >
    <script data-cfasync="false">
  
  var fujiThemeData = localStorage.getItem('fuji_data-theme');
  
  if (!fujiThemeData) {
    localStorage.setItem('fuji_data-theme', 'auto');
  } else {
    
    if (fujiThemeData !== 'auto') {
      document.body.setAttribute('data-theme', fujiThemeData === 'dark' ? 'dark' : 'light');
    }
  }
</script>

    <header>
    <div class="container-lg clearfix">
        <div class="col-12 header">
            <a class="title-main" href="/">OffSummer</a>
            
            <span class="title-sub">Summer is going, but autumn does not come yet.</span>
            
        </div>
    </div>
</header>

    <main>
        <div class="container-lg clearfix">
            
            <div class="col-12 col-md-9 float-left content">
                
<article>
    
    <h2 class="post-item post-title">
        <a href="/post/pso/">PSO粒子群算法</a>
    </h2>
    <div class="post-item post-meta">
        <span><i class="iconfont icon-today-sharp"></i>&nbsp;0001-01-01</span>

<span><i class="iconfont icon-file-tray-sharp"></i>&nbsp;1238 字</span>
<span><i class="iconfont icon-time-sharp"></i>&nbsp;3 分钟</span>
<span><i class="iconfont icon-pricetags-sharp"></i>&nbsp;<a href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0">机器学习</a>&nbsp;</span>

    </div>
    
    <div class="post-content markdown-body">
        <h2 id="概述">概述</h2>
<p>粒子群算法的思想源于对鸟群觅食行为的研究，鸟群通过集体的信息共享使群体找到最优的目的地。</p>
<p>鸟群在森林中随机搜索食物，它们想要找到食物量最多的位置。但是所有的鸟都不知道食物具体在哪个位置，只能感受到食物大概在哪个方向。每只鸟沿着自己判定的方向进行搜索，并在搜索的过程中记录自己曾经找到过食物且量最多的位置，同时所有的鸟都共享自己每一次发现食物的位置以及食物的量，这样鸟群就知道当前在哪个位置食物的量最多。在搜索的过程中每只鸟都会根据自己记忆中食物量最多的位置和当前鸟群记录的食物量最多的位置调整自己接下来搜索的方向。鸟群经过一段时间的搜索后就可以找到森林中哪个位置的食物量最多。</p>
<h2 id="组成">组成</h2>
<p>粒子群规模$N$，粒子序号$i$；粒子维度$D$，粒子维度序号$d$；迭代次数$k$；惯性权重$\omega$；个体学习因子$c_1$，群体学习因子$c_2$；随机数$r_1,r_2$，区间$[0,1]$，用于增加搜索随机性；粒子第$k$次迭代后，第$d$维度的历史最优位置$p^{k}<em>{id,pbest}$；全局第$k$次迭代后，第$d$维度的历史最优位置$p^{k}</em>{d,gbest}$。</p>
<h3 id="速度更新">速度更新</h3>
<p>$$
v^{k+1}<em>{id}=w^{k}</em>{id}+c_1r_1(p^{k}<em>{id,pbest}-x^{k}</em>{id})+c_2r_2(p^{k}<em>{d,gbest}-x^{k}</em>{id})
$$</p>
<p>第一项：惯性部分，由惯性权重和粒子自身速度构成，表示粒子对先前自身运动状态的信任。
第二项：认知部分，表示粒子本身的思考，即粒子自己经验的部分，可理解为粒子当前位置与</p>
<h3 id="位置更新">位置更新</h3>
<p>$$
x^{k+1}<em>{id}=x^k</em>{id}+v^{k+1}_{id}
$$</p>
<h3 id="初始化">初始化</h3>
<p>粒子群规模：推荐取值范围：[20,1000]，简单问题一般取20~40，较难或特定类别的问题可以取100~200。
迭代次数：推荐取值范围：[50,100]，典型取值：60、70、100。
惯性权重：取1时，退化成基本粒子群算法，取0时，失去对粒子本身经验的思考。推荐取值范围：[0.4,2]，典型取值：0.9、1.2、1.5、1.8。
学习因子：低的值使粒子在目标区域外徘徊，而高的值导致粒子越过目标区域。 推荐取值范围：[0,4]；典型取值：c1=c2=2、c1=1.6和 c2=1.8 、c1=1.6和 c2=2 ，针对不同的问题有不同的取值，一般通过在一个区间内试凑来调整这两个值。</p>
<h2 id="性能">性能</h2>
<h3 id="优缺点">优缺点</h3>
<p>具有收敛速度快、参数少、算法简单易实现的优点，但对高维度优化问题，比遗传算法更快收敛于最优解，也存在会陷入局部最优的问题。</p>
<h3 id="改进">改进</h3>
<h4 id="最大速度">最大速度</h4>
<ol>
<li>采用截断最大速度</li>
<li>动态限制最大速度，随着迭代次数增加逐步降低</li>
</ol>
<h4 id="惯性权重">惯性权重</h4>
<ol>
<li>线性调节</li>
</ol>
<p>$$
\omega=\omega_{max}-(\omega_{max}-\omega_{min})\times\frac{iter}{iter_{max}}
$$</p>
<ol>
<li>非线性调节</li>
</ol>
<p>$$
\omega=(\omega_{max}-\omega_{min})\times{\frac{T-t}{T}}^n+\omega_{min}
$$</p>
<p>$$
\omega=\frac{\omega_{max}-\omega_{min}}{2}\times\cos\frac{\pi t}{T}+\frac{\omega_{max}+\omega_{min}}{2}
$$</p>
<p>$$
\omega=(\omega_{max}-\omega_{min})\times{\frac{m-mod(t,m)}{m}}+\omega_{min}
$$</p>
<p>$$
\omega=\left{\begin{matrix} \omega_{min}+\frac{(\omega_{max}-\omega_{min})(f_i-f_{min})}{f_{avg}-f_{min}}+ &amp; f_i \le f_{avg} \ \omega_{max} &amp; f_i \gt f_{avg} \end{matrix} \right.
$$</p>
<h4 id="学习因子">学习因子</h4>
<ol>
<li>$\left{ \begin{matrix} c_1=(c_{1f}-c_{1i})\frac{t}{T}+c_{1i} \ c_2=(c_{2f}-c_{2i})\frac{t}{T}+c_{2i}\end{matrix} \right.$</li>
<li>$\left{ \begin{matrix} c_1=\partial \sin((1-\frac{t}{T})\times \frac{\pi}{2})+\delta \ c_2=\partial \cos((1-\frac{t}{T})\times \frac{\pi}{2})+\delta\end{matrix} \right.$</li>
</ol>
<h4 id="优化变异">优化变异</h4>
<ol>
<li>主动变异：与遗传算法相互结合</li>
<li>被动变异：在精英解集连续几代无改进时，以一定的规则随机生成N个粒子取代精英解集中最差的N个粒子，起到帮助群体跳出局部最优的作用。</li>
</ol>
<h4 id="优化编码">优化编码</h4>
<p>可采用二进制编码、十进制编码、实数编码、随机键编码、概率幅度编码等。</p>
<h2 id="参考资料">参考资料</h2>
<ol>
<li><a href="https://zhuanlan.zhihu.com/p/346355572" target="_blank">粒子群优化算法(Particle Swarm Optimization, PSO)的详细解读 - 知乎 (zhihu.com)</a></li>
<li>吕柏行,郭志光,赵韦皓,张凡.标准粒子群算法的优化方式综述[J].科学技术创新,2021(28):33-37.</li>
</ol>
    </div>
</article>




            </div>
            <aside class="col-12 col-md-3 float-left sidebar">
    
    <div class="sidebar-item sidebar-pages">
        <h3>页面</h3>
        <ul>
            
            <li>
                <a href="/">Home</a>
            </li>
            
            <li>
                <a href="/archives/">Archives</a>
            </li>
            
            <li>
                <a href="/about/">About</a>
            </li>
            
            <li>
                <a href="/search/">Search</a>
            </li>
            
            <li>
                <a href="/index.xml">RSS</a>
            </li>
            
        </ul>
    </div>
    
    <div class="sidebar-item sidebar-links">
        <h3>链接</h3>
        <ul>
            
            <li>
                <a href="https://github.com/ruaqy" target="_blank"><span>GitHub</span></a>
            </li>
            
            <li>
                <a href="https://gitee.com/ruqy" target="_blank"><span>Gitee</span></a>
            </li>
            
            <li>
                <a href="https://space.bilibili.com/13382902" target="_blank"><span>Bilibili</span></a>
            </li>
            
        </ul>
    </div>
    
    <div class="sidebar-item sidebar-tags">
        <h3>标签</h3>
        <div>
            
            <span>
                <a href="/tags/dl/">DL</a>
            </span>
            
            <span>
                <a href="/tags/make-up/">Make Up</a>
            </span>
            
            <span>
                <a href="/tags/matlab/">MATLAB</a>
            </span>
            
            <span>
                <a href="/tags/mindspore/">mindspore</a>
            </span>
            
            <span>
                <a href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">机器学习</a>
            </span>
            
        </div>
    </div>
    <div class="sidebar-item sidebar-toc">
        <h3>目录</h3><nav id="TableOfContents">
  <ul>
    <li><a href="#概述">概述</a></li>
    <li><a href="#组成">组成</a>
      <ul>
        <li><a href="#速度更新">速度更新</a></li>
        <li><a href="#位置更新">位置更新</a></li>
        <li><a href="#初始化">初始化</a></li>
      </ul>
    </li>
    <li><a href="#性能">性能</a>
      <ul>
        <li><a href="#优缺点">优缺点</a></li>
        <li><a href="#改进">改进</a></li>
      </ul>
    </li>
    <li><a href="#参考资料">参考资料</a></li>
  </ul>
</nav></div>
</aside>

        </div>
        <div class="btn">
    <div class="btn-menu" id="btn-menu">
        <i class="iconfont icon-grid-sharp"></i>
    </div>
    <div class="btn-toggle-mode">
        <i class="iconfont icon-contrast-sharp"></i>
    </div>
    <div class="btn-scroll-top">
        <i class="iconfont icon-chevron-up-circle-sharp"></i>
    </div>
</div>
<aside class="sidebar-mobile" style="display: none;">
  <div class="sidebar-wrapper">
    
    <div class="sidebar-item sidebar-pages">
        <h3>页面</h3>
        <ul>
            
            <li>
                <a href="/">Home</a>
            </li>
            
            <li>
                <a href="/archives/">Archives</a>
            </li>
            
            <li>
                <a href="/about/">About</a>
            </li>
            
            <li>
                <a href="/search/">Search</a>
            </li>
            
            <li>
                <a href="/index.xml">RSS</a>
            </li>
            
        </ul>
    </div>
    
    <div class="sidebar-item sidebar-links">
        <h3>链接</h3>
        <ul>
            
            <li>
                <a href="https://github.com/ruaqy" target="_blank"><span>GitHub</span></a>
            </li>
            
            <li>
                <a href="https://gitee.com/ruqy" target="_blank"><span>Gitee</span></a>
            </li>
            
            <li>
                <a href="https://space.bilibili.com/13382902" target="_blank"><span>Bilibili</span></a>
            </li>
            
        </ul>
    </div>
    
    <div class="sidebar-item sidebar-tags">
        <h3>标签</h3>
        <div>
            
            <span>
                <a href="/tags/dl/">DL</a>
            </span>
            
            <span>
                <a href="/tags/make-up/">Make Up</a>
            </span>
            
            <span>
                <a href="/tags/matlab/">MATLAB</a>
            </span>
            
            <span>
                <a href="/tags/mindspore/">mindspore</a>
            </span>
            
            <span>
                <a href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">机器学习</a>
            </span>
            
        </div>
    </div>
    
    
    
    <div class="sidebar-item sidebar-toc">
        <h3>目录</h3>
        <nav id="TableOfContents">
  <ul>
    <li><a href="#概述">概述</a></li>
    <li><a href="#组成">组成</a>
      <ul>
        <li><a href="#速度更新">速度更新</a></li>
        <li><a href="#位置更新">位置更新</a></li>
        <li><a href="#初始化">初始化</a></li>
      </ul>
    </li>
    <li><a href="#性能">性能</a>
      <ul>
        <li><a href="#优缺点">优缺点</a></li>
        <li><a href="#改进">改进</a></li>
      </ul>
    </li>
    <li><a href="#参考资料">参考资料</a></li>
  </ul>
</nav>
    </div>
    
    
  </div>
</aside>
    </main>

    <footer>
    <div class="container-lg clearfix">
        <div class="col-12 footer">
            
            <p>
                除特殊注明部分，本站内容采用 <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 进行许可。
            </p>
            
            <span>&copy; 2023-2023
                <a href="/">RQY</a>
                 | <a href="https://github.com/dsrkafuu/hugo-theme-fuji">Source code</a> 
                | 基于 <a href="https://github.com/dsrkafuu/hugo-theme-fuji/"
                   target="_blank">Fuji-v2</a> &amp; <a href="https://gohugo.io/"
                                                    target="_blank">Hugo</a> 构建
            </span>
        </div>
    </div>
</footer>

    
<script defer src="https://cdn.jsdelivr.net/npm/medium-zoom@1.0.6/dist/medium-zoom.min.js" integrity="sha512-N9IJRoc3LaP3NDoiGkcPa4gG94kapGpaA5Zq9/Dr04uf5TbLFU5q0o8AbRhLKUUlp8QFS2u7S+Yti0U7QtuZvQ==" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/lazysizes@5.3.2/lazysizes.min.js" integrity="sha512-q583ppKrCRc7N5O0n2nzUiJ+suUv7Et1JGels4bXOaMFQcamPk9HjdUknZuuFjBNs7tsMuadge5k9RzdmO+1GQ==" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/prismjs@1.27.0/components/prism-core.min.js" integrity="sha512-LCKPTo0gtJ74zCNMbWw04ltmujpzSR4oW+fgN+Y1YclhM5ZrHCZQAJE4quEodcI/G122sRhSGU2BsSRUZ2Gu3w==" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/prismjs@1.27.0/plugins/autoloader/prism-autoloader.min.js" integrity="sha512-GP4x8UWxWyh4BMbyJGOGneiTbkrWEF5izsVJByzVLodP8CuJH/n936+yQDMJJrOPUHLgyPbLiGw2rXmdvGdXHA==" crossorigin="anonymous"></script>



<script defer src="/assets/js/fuji.min.645f1123be695831f419ab54c1bcba327325895c740014006e57070d4f3e5d6b553e929c4b46f40ea707249e9c7f7c2a446d32a39ce7319f80a34525586a8e0f.js" integrity="sha512-ZF8RI75pWDH0GatUwby6MnMliVx0ABQAblcHDU8&#43;XWtVPpKcS0b0DqcHJJ6cf3wqRG0yo5znMZ&#43;Ao0UlWGqODw=="></script>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.css" integrity="sha512-07YhC3P4/vS5HdgGuNAAeIxb5ee//efgRNo5AGdMtqFBUPYOdQG/sDK0Nl5qNq94kdEk/Pvu8pmN4GYUeucUkw==" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.js" integrity="sha512-aMDiFsrEV3KzAn9EHwyBRS7y1APjZWt/Z/73ukLN2Ca2KcGGzlOQFQSnfOdnEcehpwMaQ8edlDB/0cMX2GsHbg==" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/contrib/auto-render.min.js" integrity="sha512-ZA/RPrAo88DlwRnnoNVqKINnQNcWERzRK03PDaA4GIJiVZvGFIWQbdWCsUebMZfkWohnfngsDjXzU6PokO4jGw==" crossorigin="anonymous"></script>
<script>
  renderMathInElement(document.querySelector('div.content'), {
    delimiters: [
      { left: '$$', right: '$$', display: true },
      { left: '\\[', right: '\\]', display: true },
      { left: '$', right: '$', display: false },
      { left: '\\(', right: '\\)', display: false },
    ],
  });
</script>




</body>

</html>
